<template>
  <div>
    <!-- 表格 -->
    <el-table :data="rights.rightsList" border stripe>
      <el-table-column type="index" label="#" />
      <el-table-column label="权限名称" prop="authName" />
      <el-table-column label="权限路径" prop="path" sortable />
      <el-table-column label="权限等级" prop="level" sortable>
        <!-- 权限等级插槽 -->
        <template v-slot="scope">
          <!-- tag 标签 -->
          <el-tag :type="scope.row.level == 0 ? '' : scope.row.level == 1 ? 'success' : 'danger'">
            {{ levelFilter(scope.row.level) }}
          </el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import useStore from '@/pinia/index.js';
const { rights } = useStore();
// 获取数据
rights.REQUEST_rightsList();
// 权限等级过滤器
const levelFilter = (level) => {
  return level == 0 ? '一级' : level == 1 ? '二级' : '三级';
}
</script>

<style scoped>
</style>